
package com.datawin.taotaocheche.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.ArrayList;
import java.util.List;

import com.datawin.taotaocheche.R;
import com.datawin.taotaocheche.bean.BillInfo;

/**
 * chenjian
 */
public class BillAdapter extends SuperBaseAdapter<BillInfo> {

    List<BillInfo> mData = new ArrayList<>();

    public BillAdapter(Context context, List<BillInfo> data) {
        super(context, data);
        mData = data;
    }

    @Override
    protected void convert(BaseViewHolder holder, BillInfo item, int position) {
        TextView year = holder.getView(R.id.item_bill_title);
        holder.setText(R.id.item_bill_week, item.getWeek()).setText(R.id.item_bill_time, item.getCreateTime()).setText(R.id.item_bill_money, (item.getType().equals("in")?"充值  ":"消费  ")+item.getAmount() + "元");
        year.setText(item.getMouth());
        if (position == 0) {
            year.setVisibility(View.VISIBLE);
        } else {
            if (mData.get(position).getMouth().equals(mData.get(position - 1).getMouth())) {
                year.setVisibility(View.GONE);
            } else {
                year.setVisibility(View.VISIBLE);
            }
        }

    }

    @Override
    protected int getItemViewLayoutId(int position, BillInfo item) {
        return R.layout.item_bill;
    }

}
